package joymouse;

import joymouse.logger.Logger;
import net.java.games.input.Component;
import net.java.games.input.Controller;

/**
 * Common base class for mouse position controllers, such as
 * {@link AbsoluteMouseController} or {@link RelativeMouseController}.
 *
 * @author Ben Wolsieffer
 */
public abstract class MouseController extends DeviceController {

    protected Component xAxis;
    protected Component yAxis;

    public MouseController(Controller cont) {
        super(cont);
        Component[] components = controller.getComponents();
        for (Component com : components) {
            Component.Identifier iden = com.getIdentifier();
            if (iden == Component.Identifier.Axis.X && com.isAnalog()) {
                xAxis = com;
                Logger.getLogger().log("X axis assigned to " + com);
            } else if (iden == Component.Identifier.Axis.Y && com.isAnalog()) {
                yAxis = com;
                Logger.getLogger().log("Y axis assigned to " + com);
            }
        }
    }
}
